#coding=utf-8
from django.db import models
from exday import Exday

class AveragePrice(models.Model):
    exday = models.ForeignKey(Exday, unique=True)
    
    ap3 = models.DecimalField( max_digits=8, decimal_places=2, null=True, blank=True)
    ap5 = models.DecimalField( max_digits=8, decimal_places=2, null=True, blank=True)
    ap10 = models.DecimalField( max_digits=8, decimal_places=2, null=True, blank=True)
    ap20 = models.DecimalField( max_digits=8, decimal_places=2, null=True, blank=True)
    ap30 = models.DecimalField( max_digits=8, decimal_places=2, null=True, blank=True)
    ap60 = models.DecimalField( max_digits=8, decimal_places=2, null=True, blank=True)
    ap120 = models.DecimalField( max_digits=8, decimal_places=2, null=True, blank=True)
    ap240 = models.DecimalField( max_digits=8, decimal_places=2, null=True, blank=True)
    class Admin:pass
    
    def __unicode__(self):
        ap =  unicode("平均价格", 'u8')
        return "%s on %s of %s"%(ap, self.exday.date.isoformat(),self.exday.share.name)
    class Meta:
        app_label = 'shstock'
            
class AverageVolume(models.Model):
    exday = models.ForeignKey(Exday, unique=True)
    
    av3 = models.IntegerField(null=True, blank=True)
    av5 = models.IntegerField(null=True, blank=True)
    av10 = models.IntegerField(null=True, blank=True)
    av20 = models.IntegerField(null=True, blank=True)
    av30 = models.IntegerField(null=True, blank=True)
    av60 = models.IntegerField(null=True, blank=True)
    av120 = models.IntegerField(null=True, blank=True)
    av240 = models.IntegerField(null=True, blank=True)
    
    ahsl3 = models.DecimalField( max_digits=6, decimal_places=2, null=True, blank=True )
    ahsl5 = models.DecimalField( max_digits=6, decimal_places=2, null=True, blank=True )
    ahsl10 = models.DecimalField( max_digits=6, decimal_places=2, null=True, blank=True )
    ahsl20 = models.DecimalField( max_digits=6, decimal_places=2, null=True, blank=True )
    ahsl30 = models.DecimalField( max_digits=6, decimal_places=2, null=True, blank=True )
    ahsl60 = models.DecimalField( max_digits=6, decimal_places=2, null=True, blank=True )
    ahsl120 = models.DecimalField( max_digits=6, decimal_places=2, null=True, blank=True )
    ahsl240 = models.DecimalField( max_digits=6, decimal_places=2, null=True, blank=True )
    
    def __unicode__(self):
        av =  unicode("平均成交量", 'u8')
        return "%s on %s of %s"%(av, self.exday.date.isoformat(),self.exday.share.name)
    class Meta:
        app_label = 'shstock'

